home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / a_man / cat7 / pty.z / pty
Encoding:
Text File  |  2002-10-03  |  4.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. PPPPTTTTYYYY((((7777MMMM))))                                                                PPPPTTTTYYYY((((7777MMMM))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      pty, pts - pseudo terminal driver
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      The _p_t_y driver provides a device-pair termed a _p_s_e_u_d_o _t_e_r_m_i_n_a_l.  A pseudo
  13.      terminal is a pair of character devices, a _m_a_s_t_e_r device and a _s_l_a_v_e
  14.      device.  The slave device provides processes an interface identical to
  15.      that described in _t_e_r_m_i_o(7).  However, whereas all other devices which
  16.      provide the interface described in _t_e_r_m_i_o(7) have a hardware device of
  17.      some sort behind them, the slave device has, instead, another process
  18.      manipulating it through the master half of the pseudo terminal.  That is,
  19.      anything written on the master device is given to the slave device as
  20.      input and anything written on the slave device is presented as input on
  21.      the master device.
  22.  
  23.      The following _i_o_c_t_l calls apply only to pseudo terminals:
  24.  
  25.      TIOCPKT
  26.           Enable/disable _p_a_c_k_e_t mode.  Packet mode is enabled by specifying
  27.           (by reference) a nonzero parameter and disabled by specifying (by
  28.           reference) a zero parameter.  When applied to the master side of a
  29.           pseudo terminal, each subsequent _r_e_a_d from the terminal will return
  30.           data written on the slave part of the pseudo terminal preceded by a
  31.           zero byte (symbolically defined as TIOCPKT_DATA), or a single byte
  32.           reflecting control status information.  In the latter case, the byte
  33.           is an inclusive-or of zero or more of the bits:
  34.  
  35.           TIOCPKT_FLUSHREAD
  36.                whenever the read queue for the terminal is flushed.
  37.  
  38.           TIOCPKT_FLUSHWRITE
  39.                whenever the write queue for the terminal is flushed.
  40.  
  41.           TIOCPKT_STOP
  42.                whenever output to the terminal is stopped a la ^S.
  43.  
  44.           TIOCPKT_START
  45.                whenever output to the terminal is restarted.
  46.  
  47.           TIOCPKT_DOSTOP
  48.                whenever _t__s_t_o_p_c is ^S and _t__s_t_a_r_t_c is ^Q.
  49.  
  50.           TIOCPKT_NOSTOP
  51.                whenever the start and stop characters are not ^S/^Q.
  52.  
  53.           This mode is used by _r_l_o_g_i_n(1C) and _r_l_o_g_i_n_d(1M) to implement a
  54.           remote-echoed, locally ^S/^Q flow-controlled remote login with
  55.           proper back-flushing of output; it can be used by other similar
  56.           programs.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPTTTTYYYY((((7777MMMM))))                                                                PPPPTTTTYYYY((((7777MMMM))))
  71.  
  72.  
  73.  
  74. AAAALLLLLLLLOOOOCCCCAAAATTTTIIIIOOOONNNN
  75.      The code sequence shown below demonstrates how to allocate pseudo
  76.      terminals.  Pseudo terminals, like all files, must have the correct file
  77.      permissions to be accessible.  The ____ggggeeeettttppppttttyyyy(3) library function takes care
  78.      of this problem.
  79.  
  80.      #include <fcntl.h>
  81.      #include <unistd.h>
  82.  
  83.      /*
  84.       * Find a pseudo tty to use and open both sides.
  85.       *  filedes[0] receives the master file descriptor while filedes[1]
  86.       *  receives the slave.  The master is opened with O_NDELAY as commonly
  87.       *  needed in daemons such as rlogind and telnetd.
  88.       */
  89.      int                 /* -1 on failure */
  90.      findPseudoTTY(int *filedes)
  91.      {
  92.          char *line;
  93.  
  94.          line = _getpty(&filedes[0], O_RDWR|O_NDELAY, 0600, 0);
  95.          if (0 == line)
  96.              return -1;
  97.          if (0 > (filedes[1] = open(line, O_RDWR))) {
  98.              (void)close(filedes[0]);
  99.              return -1;
  100.          }
  101.          return 0;
  102.      }
  103.  
  104. FFFFIIIILLLLEEEESSSS
  105.      /dev/ptc                      - master pseudo terminal
  106.      /dev/tty[qrstuvwxyz][0-99]    - slave pseudo terminals
  107.      /dev/pts                      - equivalent to /dev/ttyq[0-9]
  108.  
  109. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  110.      getpty(3)
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.